//
//  MYGResumeApi.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/4/15.
//

import UIKit
import Moya

enum MYGResumeApi {
    case personalInfo
    case englishPersonInfo(doctor_id:Int)//英文简历
    case mediaoInfo(doctor_id:Int)//媒体简历
    case exportResume(send_to:String,type:Int)//下载简历
    case editInfo(phone:String,address:String,email:String,index:String)
    case editResume(ext:[[String: String]],index:String)//简历教育经历
    case editWork(ext:[[String: String]],index:String)//工作经历
    
    case editMineResum(param:[String:Any])//编辑简历
    case editDoctorBaseInfo(param:[String:Any])//编辑医生个人信息

    
    case editSkill(ext:[[String: String]],index:String)//擅长领域
    case editLiterature(index:String)//编辑文献
    case editPatent(ext:[[String: String]],index:String)//编辑专利
    case editPublish(ext:[[String: String]],index:String)//编辑出版
    case editHonor(ext:[[String: String]],index:String)//编辑荣誉
    case editCustom(ext:[[String: String]],index:String)//编辑自定义
    
    case hospitals(kwd: String,hosp_type:String,hosp_level:String,address:String,page:Int)//医院列表
    case getSubjectList(params: [String: Any])//获取科室列表
    case editMedia(id:String,content:String)
}

extension MYGResumeApi: MYGTargetType {

    var params: [String : Any] {
        var params: [String: Any] = [:]
        switch self {
        case let .personalInfo:
            break
        case let .englishPersonInfo(doctor_id):
            params["doctor_id"] = doctor_id
        case let .mediaoInfo(doctor_id):
            params["doctor_id"] = doctor_id
        case let .exportResume(send_to, type):
            params["send_to"] = send_to
            params["type"] = type
        case let .editResume(ext, index ):
            params["ext"] = ext
            params["index"] = index
        case let .editWork(ext, index ):
            params["ext"] = ext
            params["index"] = index
        case let .editSkill(ext, index ):
            params["ext"] = ext
            params["index"] = index
        case let .editMineResum(param):
            return param
        case let .editInfo(phone, address, email, index):
            params["phone"] = phone
            params["address"] = address
            params["email"] = email
            params["index"] = "1"
        case let .editLiterature(index):
            params["index"] = index
        case let .editPatent(ext, index):
            params["ext"] = ext
            params["index"] = index
        case let .editPublish(ext, index):
            params["ext"] = ext
            params["index"] = index
        case let .editHonor(ext, index):
            params["ext"] = ext
            params["index"] = index
        case let .editCustom(ext, index):
            params["ext"] = ext
            params["index"] = index
        case let .editDoctorBaseInfo(param):
            return param
        case let .getSubjectList(params):
            return params
        case let .hospitals(kwd, hosp_type, hosp_level, address,page):
            params["kwd"] = kwd
            params["hosp_type"] = hosp_type
            params["hosp_level"] = hosp_level
            params["address"] = address
            params["page"] = page
            params["pageSize"] = 20
        case let .editMedia(id, content):
            params["id"] = id
            params["content"] = content
        }
        return params
    }
    
    var path: String {
        switch self {
        case .personalInfo:
            "/doctor/h5-personal-info"
        case .englishPersonInfo:
            "/doctor/h5-en-personal-info"
        case .exportResume:
            "/resume/export"
        case .editResume:
            "/doctor/h5-ext-update-learning"
        case .editWork:
            "/doctor/h5-ext-update-work"
        case .editSkill:
            "/doctor/h5-ext-update-skilled"
        case .editMineResum:
            "/doctor/h5-info-update"
        case .editInfo:
            "/doctor/h5-ext-update-contact"
        case .editLiterature:
            "/doctor/h5-ext-update-literature"
        case .editPatent:
            "/doctor/h5-ext-update-patent"
        case .editPublish:
            "/doctor/h5-ext-update-publish"
        case .editHonor:
            "/doctor/h5-ext-update-honor"
        case .editCustom:
            "/doctor/h5-ext-update-custom"
        case .mediaoInfo:
            "/doctor/h5-media-info"
        case .editDoctorBaseInfo:
            "/doctor/h5-base-info-update"
        case .getSubjectList:
            "api/department/subject_all_list"
        case .hospitals:
            "/api/hospital/hospitals"
        case .editMedia:
            "/doctor/h5-ext-update-media"
        }
    }
    
    var baseURL: URL {
        switch self {
        case .englishPersonInfo,.mediaoInfo,.getSubjectList,.hospitals:
            return  URL(string: BaseUrl)!
        case .personalInfo,.exportResume,.editResume,.editWork,.editSkill,.editMineResum,.editInfo,.editLiterature,.editPatent,.editPublish,.editHonor,.editCustom,.editDoctorBaseInfo,.editMedia:
            return  URL(string: Url)!
        }
    }
    
    var method: Moya.Method {
        switch self {
        case .personalInfo,.getSubjectList,.hospitals:
                .get
        case .englishPersonInfo:
                .get
        case .exportResume:
                .get
        case .editResume,.editDoctorBaseInfo,.editMedia:
                .post
        case .editWork:
                .post
        case .editSkill:
                .post
        case .editMineResum:
                .post
        case .editInfo:
                .post
        case .editLiterature:
                .post
        case .editPatent:
                .post
        case .editPublish:
                .post
        case .editHonor:
                .post
        case .editCustom:
                .post
        case .mediaoInfo:
                .get
        }
    }
    
}
